import http from "@/api";
import qs from "qs";
import axios from "axios";
//获取日常工作列表
export const getDailyWorkList = params => {
  console.log(params);
  return http.post(
    `/pages/request!findyunweizongjieByPage.action`,
    qs.stringify({
      "yunweizongjieQueryDTO.ecategoryName": params.ecategoryName,
      "yunweizongjieQueryDTO.technicianNo": params.technicianNo,
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "eno",
      sord: "Id"
    })
  );
};
//提交新增编辑日常工作
export const addDailyWork = (params, eavparams) => {
  Object.keys(eavparams).forEach(key => {
    params["yunweiZongJieDTO.attrVals['" + `${key}` + "']"] = `${eavparams[key]}` == undefined ? "" : `${eavparams[key]}`;
  });

  return http.post(`/pages/request!saveyunweizongjie.action`, qs.stringify(params));
};
//提交编辑日常工作
export const editDailyWork = (params, eavparams) => {
  Object.keys(eavparams).forEach(key => {
    params["yunweiZongJieDTO.attrVals['" + `${key}` + "']"] = `${eavparams[key]}` == undefined ? "" : `${eavparams[key]}`;
  });
  return http.post(`/pages/request!updateyunweizongjie.action`, qs.stringify(params));
};
//删除日常工作
export const deleteDailyWork = params => {
  return http.post(`/pages/request!delteyunwei.action?` + params);
};
//查看日常工作详情
export const getDailyWorkInfo = params => {
  return http.post(`/pages/request!findByyunweizongjie.action?` + params);
};
//导出文档
export const prdWord = params => {
  return http.downloaditsm(`/pages/request!prdWord.action`, qs.stringify(params));
};

//获取自定义类型
export const findEavEntity = () => {
  return http.post(
    `/pages/eav!findEavEntity.action`,
    qs.stringify({
      _search: false,
      rows: 9999,
      page: 1,
      sidx: "eavNo",
      sord: "desc"
    })
  );
};

//获取日常工作列表
export const findAttrs = params => {
  console.log(params);
  return http.post(
    `/pages/attrs!find.action?attrsQueryDTO.eavNo=` + params,
    qs.stringify({
      _search: false,
      rows: 9999,
      page: 1,
      sidx: "sortNo",
      sord: "Id"
    })
  );
};

//查看报表图片
export const findPictureDataByName = params => {
  return http.post(`/pages/request!findPictureData.action?time=` + Date.now() + Math.random(), qs.stringify(params));
};
